<html>

<head>
    <meta charset="UTF-8">
    <script>
        setInterval(() => {
            var req = new XMLHttpRequest();
            req.open("GET", "/sensor");
            req.send();
            req.onloadend = function () {
                console.log(req.responseText);
                sensor = JSON.parse(req.responseText);
                document.getElementById("temp").innerText = "温度：" + sensor.temp;
                document.getElementById("humi").innerText = "湿度：" + sensor.humi + "%";
            }
        }, 1000);
    </script>
</head>

<body>
    <p id="temp"></p>
    <p id="humi"></p>
</body>

</html>